package qc.module.ehs.mapper;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import qc.module.ehs.dto.edurecord.EduRecordDto;
import qc.module.ehs.entity.EhsEduRecord;

import java.util.List;

/**
 * EhsEduRecordMapper
 *
 * @author QuCheng Tech
 * @create 2024/10/29
 */
@Mapper
public interface EhsEduRecordMapper {
    EhsEduRecordMapper MAPPER = Mappers.getMapper(EhsEduRecordMapper.class);

    /**
     * entity -> dto
     * @param en
     * @return
     */
    @Mapping(target = "begintm", source = "begintm", dateFormat = "yyyy-MM-dd HH:mm:ss")
    @Mapping(target = "endtm", source = "endtm", dateFormat = "yyyy-MM-dd HH:mm:ss")
    EduRecordDto toDto(EhsEduRecord en);

    /**
     * List<entity> -> List<dto>
     * @param ens
     * @return
     */
    List<EduRecordDto> toDtoList(List<EhsEduRecord> ens);

    /**
     * dto -> entity
     * @param dto
     * @return
     */
    @Mapping(target = "begintm", source = "begintm", dateFormat = "yyyy-MM-dd HH:mm:ss")
    @Mapping(target = "endtm", source = "endtm", dateFormat = "yyyy-MM-dd HH:mm:ss")
    EhsEduRecord toEntity(EduRecordDto dto);
}
